$('.form-horizontal').validate({
        rules: {
            username: {
                required: true, 
                minlength: 4, 
                maxlength: 12, 
            },
            password: {
                required: true, 
                minlength: 6, 
                maxlength: 16, 
            },
            passwords: {
                required: true, 
                minlength: 6, 
                maxlength: 16, 
                equalTo: '#inputPassword3'
            },
            tel: {
                required: true,
                number: true,
                minlength: 5,
                maxlength: 11
            },
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            username: {
                required: '用户名不能为空', 
                minlength: '长度最小6位', 
                maxlength: '长度最大12位', 
            },
            password: {
                required: '密码不能为空', 
                minlength: '长度最小6位', 
                maxlength: '长度最大16位', 

            },
            passwords: {
                required: '确认密码不能为空', 
                minlength: '长度最小6位', 
                maxlength: '长度最大16位', 
                equalTo: '两次密码必须一致！'
            },
            tel: {
                required: '手机号不能为空',
                number: '请输入合法的手机号',
                minlength: '最短5位',
                maxlength: '最长11位'
            },
            email: {
                required: '邮箱不能为空',
                email: '请填写正确的邮箱格式'
            }
        },
// 表单提交
submitHandler: function (form) {
        let formData = $('.form-horizontal').serialize()
        let loadid = layer.load(1, {
            shade: [0.5, '#000']
        })
        sendAjax({
            method: 'post',             
            url: '/users/api/register',
            data: formData,
            success: res => {
                let {
                    errorCode,
                    message
                } = res
                if (errorCode == 0) {
                    layer.msg(message, {
                        icon: 1,
                        time: 2000
                    }, function () {
                        layer.close(loadid)
                        location.href = '/login.html'
                    })
                } else {
                    layer.msg(message, {
                        icon: 2,
                        time: 2000
                    })
                    layer.close(loadid)
                }
            }
        })
    }
})

$('#inputeamil3').on('focus',function(){
    $('.eamil-tips')[0].style.display = 'block'
})

$('#inputeamil3').on('blur',function(){
    $('.eamil-tips')[0].style.display = 'none'
})
